

const { readHTML, readJSON, readIMG } = require('../file')
const url = require('url')
const querystring = require('querystring')
const { log } = require('console')

module.exports = {
    home(req, res) {
        readHTML("./views/home.html", req, res)
    },
    login(req, res) {
        console.log(res.url);

        // get请求获取数据
        // const query = url.parse(req.url,true).query
        // console.log(query);

        // POST请求参数
        var body = ""
        req.on("data", chunk => {
            body += chunk
        })
        req.on("end", () => {
            body = querystring.parse(body)
            console.log(body);
        })
        readHTML("./views/login.html", req, res)
    },
    register(req, res) {
        readHTML("./views/register.html", req, res)
    },
    mine(req, res) {
        readHTML("./views/mine.html", req, res)
    },
    notfound(req, res) {
        readHTML("./views/404.html", req, res)
    },
    json(req, res) {
        readJSON("./data/data.json", req.res)
    },
    img1(req, res) {
        readIMG('./images/img1.jpg', req.res)
    },
    img2(req, res) {
        readIMG('./images/img2.jpg', req, res)
    }
}